﻿using GeekDesk.ViewModel;
using HandyControl.Tools;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace GeekDesk.Control.UserControls.Push
{
    /// <summary>
    /// CSDNControl.xaml 的交互逻辑
    /// </summary>
    /// 

   
    public partial class CSDNControl : UserControl
    {
        private List<HotPassageInfo> hotPassageInfos;
        GetHotPassege hotPassege = new GetHotPassege();
        public CSDNControl()
        {
            InitializeComponent();
            InitialList();
            DataContext = hotPassageInfos;


        }

        private void InitialList()
        {
            int length = Math.Min(GetHotPassege.title.Count(),GetHotPassege.content.Count());
            hotPassageInfos = new List<HotPassageInfo>();
            //hotPassageInfos.Add(new HotPassageInfo("ti", "content", "su", "web"));
            //hotPassageInfos.Add(new HotPassageInfo("ti2", "content2", "su2", "web2"));
            for (int i = 0; i < 4; i++)
            {
                hotPassageInfos.Add(new HotPassageInfo(GetHotPassege.title[i+2], GetHotPassege.content[i], GetHotPassege.summery[i], GetHotPassege.website[i]));
            }
            Lst.ItemsSource= hotPassageInfos;
        }

        private void ListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            HotPassageInfo currentItem= Lst.SelectedItem as HotPassageInfo;
            string tmp = currentItem.website.Trim();
            Process.Start(tmp);
        }

        private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            ScrollViewer scrollViewer = (ScrollViewer)sender;
            scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - e.Delta);
            e.Handled = true;
        }
    }
}
